

import java.io.*;
import java.util.Scanner;

public class Demo33 {
    public static void main(String[] args)throws IOException{
        Scanner scan = new Scanner(System.in);
        BufferedWriter wt = new BufferedWriter(new OutputStreamWriter(System.out));
        int n  = scan.nextInt();//输入p字符的长度
        String P =  scan.next();//输入p字符串
        char[] p = new char[100010];//创建p数组存字符
        for(int i = 1 ; i <= n ; i ++ ) p[i] = P.charAt(i-1);
        int m = scan.nextInt();//输入s字符串的长度
        String S = scan.next();//输入s字符串
        char[] s = new char[1000010];//创建s数组存字符
        for(int i = 1 ; i <= m ; i ++ ) s[i]  = S.charAt(i-1);
        int[] ne = new int[100010];//kmp核心数组next[];
        for(int i = 2 , j = 0; i  <= n ; i ++ ){
            while(j > 0 && p[i] != p[j+1]) j = ne[j];
            if(p[i] == p[j+1]) j ++ ;
            ne[i] = j;
        }
        for(int i = 1 ,j = 0 ; i <= m ; i ++ ){
            while(j > 0 && s[i] != p[j+1]) j = ne[j];
            if(s[i] == p[j+1]) j++;
            if(j == n){
                wt.write((i - n) + " ");
                j = ne[j];
            }
        }
        wt.close();

    }
}

